package cn.gdcp.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class AddStu_DB extends AppCompatActivity {
             private Button DB_btn;
             private EditText edit_name;
             private EditText edit_age;
             private RadioButton img1;
             private RadioButton img2;
             private RadioButton img3;

             @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_stu__db);
                    edit_age=findViewById(R.id.edit_age);
                    edit_name=findViewById(R.id.edit_name);
                    img1=findViewById(R.id.img1);
                    img2=findViewById(R.id.img2);
                    img3=findViewById(R.id.img3);





                      DB_btn=findViewById(R.id.DB_btn);




                   DB_btn.setOnClickListener(new View.OnClickListener() {
                       @Override
                       public void onClick(View view) {

                           String name=edit_name.getText().toString();
                           int age= Integer.parseInt(edit_age.getText().toString());

                          int imgId=R.drawable.d1;

                          if (img1.isChecked()){
                              imgId=R.drawable.d1;
                          }
                          else if (img2.isChecked()){
                              imgId=R.drawable.d2;
                          }
                          else if(img3.isChecked()){
                              imgId=R.drawable.d3;
                          }
                           Intent intent=new Intent();
                             intent.putExtra("NAME",name);
                             intent.putExtra("AGE",age);
                             intent.putExtra("ID",imgId);
                             setResult(2017,intent);
                             finish();


                       }
                   });
    }
}
